// Time:  O(n)
// Space: O(1)

#include <vector>
#include <string>
#include <iostream>
#include <cassert>
using namespace std;

class Solution {
public:
    vector<string> buildArray(vector<int>& target, int n) {
        vector<string> res;
        int curr = 1;
        for (const auto& t : target)  {
            for (; curr < t; ++curr) {
                res.emplace_back("Push");
                res.emplace_back("Pop");
            }
            res.emplace_back("Push");
            ++curr;
        }
        return res;
   }
};

// Test case
int main() {
    // Create the Solution object
    Solution sol;

    // Test case 1
    vector<int> target1 = {1, 3};
    int n1 = 3;
    vector<string> expected1 = {"Push", "Push", "Pop", "Push"};
    vector<string> result1 = sol.buildArray(target1, n1);
    assert(result1 == expected1);
    cout << "Test case 1 passed!" << endl;

    // Test case 2
    vector<int> target2 = {1, 2, 3};
    int n2 = 3;
    vector<string> expected2 = {"Push", "Push", "Push"};
    vector<string> result2 = sol.buildArray(target2, n2);
    assert(result2 == expected2);
    cout << "Test case 2 passed!" << endl;

    // Test case 3
    vector<int> target3 = {1, 2};
    int n3 = 4;
    vector<string> expected3 = {"Push", "Push"};
    vector<string> result3 = sol.buildArray(target3, n3);
    assert(result3 == expected3);
    cout << "Test case 3 passed!" << endl;

    // Test case 4
    vector<int> target4 = {2, 3, 4};
    int n4 = 4;
    vector<string> expected4 = {"Push", "Pop", "Push", "Push", "Push"};
    vector<string> result4 = sol.buildArray(target4, n4);
    assert(result4 == expected4);
    cout << "Test case 4 passed!" << endl;

    return 0;
}